{
  "displayName":    "Python",       
  "name":           "python",
  "mimeTypes":      ["text/x-python"],
  "fileExtensions": ["py"],
  "editorOptions": { "tabSize": 4, "insertSpaces": false },
  
  
  "lineComment": "# ",   
  
  
  

  "keywords": [
    "and", "del", "from", "not", "while",
    "as", "elif", "global", "or", "with",
    "assert", "else", "if", "pass", "yield",
    "break", "except", "import", "print",
    "class", "exec", "in", "raise", "continue", "finally", "is",
    "return", "def", "for", "lambda", "try",
    ":","=",
    "isinstance","__debug__"
  ],  

  "operators": [
    "+", "-", "*", "**", "/", "//", "%",
    "<<", ">>", "&", "|", "^", "~",
    "<", ">", "<=", ">=", "==", "!=", "<>",
    "+=", "-=", "*=", "/=", "//=", "%=",
    "&=", "|=", "^=", ">>=", "<<=", "**="  
  ],
  
  
  "brackets": [
    ["(",")","delimiter.parenthesis"],
    ["{","}","delimiter.curly"],
    ["[","]","delimiter.square"]
  ],
  
  "noindentBrackets": "\"'",

  
  "symbols":    "[=><!~&|+\\-*\\/\\^%]+",
  "delimiters": "[;=.@:,`]",
  
  
  "escapes": "\\\\(?:[abfnrtv\\\\\"'\\n\\r]|x[0-9A-Fa-f]{2}|[0-7]{3}|u[0-9A-Fa-f]{4}|U[0-9A-Fa-f]{8}|N\\{\\w+\\})",    
  "rawpre": "(?:[rR]|ur|Ur|uR|UR|br|Br|bR|BR)",  
  "strpre": "(?:[buBU])",
  
  
  "tokenizer": {
    "root": [
      
      ["@strpre?(\"\"\"|''')", { "token": "string.delim", "bracket": "@open", "next": "@mstring.$1" } ],
      ["@strpre?\"([^\"\\\\]|\\\\.)*$", "string.invalid" ],  
      ["@strpre?'([^'\\\\]|\\\\.)*$", "string.invalid" ],  
      ["@strpre?([\"'])",  { "token": "string.delim", "bracket": "@open", "next": "@string.$1" } ],

      ["@rawpre(\"\"\"|''')", { "token": "string.delim", "bracket": "@open", "next": "@mrawstring.$1" } ],
      ["@rawpre\"([^\"\\\\]|\\\\.)*$", "string.invalid" ],  
      ["@rawpre'([^'\\\\]|\\\\.)*$", "string.invalid" ],  
      ["@rawpre([\"'])",  { "token": "string.delim", "bracket": "@open", "next": "@rawstring.$1" } ],
      
      
      ["__[\\w$]*", "predefined" ],
      ["[a-z_$][\\w$]*", { "cases": { "@keywords": "keyword",
                                   "@default": "identifier" } }],
      ["[A-Z][\\w]*", { "cases": { "~[A-Z0-9_]+": "constructor.identifier",
                                "@default"   : "namespace.identifier" }}],  
      
      
      { "include": "@whitespace" },
      
      
      ["[{}()\\[\\]]", "@brackets"],
      ["@symbols", { "cases": { "@keywords" : "keyword",
                              "@operators": "operator", 
                              "@default"  : "" } } ],

      
      ["\\d*\\.\\d+([eE][\\-+]?\\d+)?",   "number.float"],
      ["0[xX][0-9a-fA-F]+[lL]?",     "number.hex"],
      ["0[bB][0-1]+[lL]?",           "number.binary"],
      ["(0[oO][0-7]+|0[0-7]+)[lL]?", "number.octal"],
      ["(0|[1-9]\\d*)[lL]?",          "number"],

      
      [":", { "token": "keyword", "bracket": "@open" }], 
      ["@delimiters", { "cases": { "@keywords": "keyword",
                                 "@default": "delimiter" }}]
      
    ],

    "comment": [
      ["[^\\/*]+", "comment" ],
      ["\\/\\*",    "comment", "@push" ],    
      ["\\*/",    "comment", "@pop"  ],
      ["[\\/*]",   "comment" ]
    ],  

    
    "mstring": [
      { "include": "@strcontent" },      
      ["\"\"\"|'''",  { "cases": { "$#==$S2":  { "token": "string.delim", "bracket": "@close", "next": "@pop" },
                              "@default": { "token": "string" } } }],
      ["[\"']", "string" ],
      [".",    "string.invalid"]
    ],

    "string": [
      { "include": "@strcontent" },      
      ["[\"']", { "cases": { "$#==$S2": { "token": "string.delim", "bracket": "@close", "next": "@pop" },
                          "@default": { "token": "string" } } } ],
      [".", "string.invalid"]
    ],
    
    "strcontent": [
      ["[^\\\\\"']+",  "string"],
      ["\\\\$",       "string.escape"],
      ["@escapes",  "string.escape"],
      ["\\\\.",       "string.escape.invalid"]     
    ],
    
    
    "mrawstring": [
      { "include": "@rawstrcontent" },      
      ["\"\"\"|'''",  { "cases": { "$#==$S2":  { "token": "string.delim", "bracket": "@close", "next": "@pop" },
                              "@default": { "token": "string" } } }],
      ["[\"']", "string" ],
      [".",    "string.invalid"]
    ],

    "rawstring": [
      { "include": "@rawstrcontent" },
      ["[\"']", { "cases": { "$#==$S2": { "token": "string.delim", "bracket": "@close", "next": "@pop" },
                          "@default": { "token": "string" } } } ],
      [".", "string.invalid"]      
    ],
    
    "rawstrcontent": [
      ["[^\\\\\"']+", "string"],
      ["\\\\[\"']",   "string"],
      ["\\\\u[0-9A-Fa-f]{4}", "string.escape"],
      ["\\\\", "string" ]
    ],

    
    "whitespace": [
      ["[ \\t\\r\\n]+", "white"],
      ["#.*$",       "comment"]
    ]
  }
}